/**
  * Author: Mei
  * Date: 2020-11-20 18:47
  * Description: 
  *
  */
#include <iostream>
#include <vector>
#include <algorithm>
#include <memory>
#include <utility>
#include <functional>
#include <numeric>

using namespace std;

bool judge(int num) {
    return (num >= 100);
}

int main() {
    //1、find和find_if算法  count()和count_if()
    vector<int> vect = {1, 2, 3, 5};
    auto it = find(vect.begin(), vect.end(), 5);
    if (it != vect.end()) {
        //cout << *it << endl;
    } else {
        cout << "不匹配" << endl;
    }

    vector<int> vect2 = {11, 24, 63, 75};
    auto it1 = find_if(vect2.begin(), vect2.end(), judge);

    if (it1 != vect2.end()) {
        cout << *it1 << endl;
    } else {
        cout << "不匹配" << endl;
    }

    //第三个参数表示总和的初始值
    cout << accumulate(vect2.begin(), vect2.end(), 7);

    //generate的使用 对向量的指定范围进行填充
    vector<int> vect3(10);
    int value = 1;
    generate(vect3.begin(), vect3.end()-2, [&value]() {
        value *= 2;
        return value;
    });
    for (auto it : vect3) {
        cout << it << endl;
    }


    unique_ptr<int> myInt(new int(3));
    *myInt = 5;
    cout << *myInt << endl;

    auto myDouble = make_shared<double>(5.4);
    cout << *myDouble << endl;

    return 0;
}